﻿Shader "Custom/NewShader" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader
    {
        pass
        {
        
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#include "unitycg.cginc"
			sampler2D _MainTex;
			struct v2f
			{
				float4 pos : SV_POSITION ;
				float2 ModeUV: TEXCOORD0;
			};

			v2f vert(appdata_base v)
			{
				v2f o;
				o.pos=mul(UNITY_MATRIX_MVP,v.vertex);  //将模型顶点坐标转换到视图坐标矩阵中
				o.ModeUV=v.texcoord;   //获取模型的UV坐标
				return o;
			}

			fixed4 frag(v2f i):COLOR
			{
				fixed4 col;
        
				col=tex2D(_MainTex,i.ModeUV);      //根据模型UV坐标获取贴图相对应的颜色
        
				return col;        
			}
			ENDCG
        
        }
    }
}  